﻿using GN.Pay.TradeChannel.DefaultImpl;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using GN.Pay.TradeChannel.WeiXin.Response;
using GN.Pay.Utils;

namespace GN.Pay.TradeChannel.WeiXin.Request
{
    [Serializable]
    class JsApiPayRequest : APayRequest
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="channel"></param>
        /// <param name="order"></param>
        /// <param name="config"></param>
        public JsApiPayRequest(IChannel channel, IOrderPayApply order, WeiXinConfigure config)
            : base(channel, order, config)
        {
            ExceptionUtils.CheckNotNull(order.ClientIP, nameof(order.ClientIP));
            ExceptionUtils.CheckNotNull(order.UserToken, nameof(order.UserToken));
            this.OpenId = order.UserToken;
        }

        public override string Trade_Type
        {
            get
            {
                return "JSAPI";
            }
        }

        /// <summary>
        /// 关注微信的公众号的 OpenId
        /// </summary>
        public string OpenId { get; set; }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="xml"></param>
        /// <returns></returns>
        protected override PayResponse CreatePayResponse(string xml)
        {
            return new JsApiPayResponse(xml);
        }
    }
}